package com.diligent.cloud.sfc.service.impl;

import com.canny.commons.model.ObjectResult;
import com.diligent.cloud.primary.data.feign.service.imat.IMatImageFeignService;
import com.diligent.cloud.sfc.service.MdmService;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

/**
 * MdmService class
 *
 * @author xf107278
 * @date 3/30/2020
 */
@Service
public class MdmServiceImpl implements MdmService {
    private IMatImageFeignService iMatImageFeignService;

    public MdmServiceImpl(IMatImageFeignService iMatImageFeignService) {
        this.iMatImageFeignService = iMatImageFeignService;
    }

    @Override
    public ResponseEntity<ObjectResult> getMouldPic(String matCode, String systemId) {
        ResponseEntity<com.diligent.cloud.primary.data.model.Result> pic =
                iMatImageFeignService.getMouldPic(matCode);
        if (pic.getBody() != null) {
            return ResponseEntity.ok(new ObjectResult(pic.getBody().getData()));
        }else {
            return ResponseEntity.ok(new ObjectResult());
        }
    }
}
